package com.yc.boot.work.api;

import com.yc.boot.common.model.response.Outcome;
import com.yc.boot.work.entity.ComplexSqlDemo;
import com.yc.boot.work.entity.CorrelationDemo;
import com.yc.boot.work.service.CorrelationDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 杨智杰
 * @since 2021/11/19 11:14
 */
@RestController
@Api(tags = "示例代码接口")
@RequestMapping("/demo")
public class CorrelationDemoApi {

    @Resource
    private CorrelationDemoService correlationDemoService;


    @GetMapping("/getCorrelationDemo")
    @ApiOperation("多表关联查询接口")
    public Outcome<List<CorrelationDemo>> getCorrelationDemo() {
        return Outcome.success(correlationDemoService.list()).setMessage("多表关联操作仅限于查询,切勿进行增删改");
    }


    @GetMapping("/getComplexSqlDemo")
    @ApiOperation("复杂SQL查询接口")
    public Outcome<ComplexSqlDemo> getComplexSqlDemo() {
        return Outcome.success(correlationDemoService.getComplexSqlDemo());
    }

}
